<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>设置</title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../fonts/iconfont/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../css/global.css" />
		<style type="text/css">
			#refresh{line-height: 22px;position: absolute;right: 15px;top:-22px;border-radius: 50%;}
			#refresh i{font-size: 22px;color: #4c968e;z-index: 10;display: block;width: 22px;height: 22px;background: #fff;}
			
			.run {
				-webkit-animation: turn_round 0.4s infinite linear;
			}
			
			@-webkit-keyframes turn_round {
				from {
					-webkit-transform: rotateZ(0deg);
				}
				to {
					-webkit-transform: rotateZ(360deg);
				}
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav bg_white">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title colorP">设置</h1>
		</header>
		<div class="mui-content">
			<div></div>
			<ul class="mui-table-view bg_white margin-bottom10px">
				<li onclick="openNewPage('about_us.html')" class="mui-table-view-cell">
					<span class="padding_tb_5px">关于我们</span>
				</li>
				<li onclick="openNewPage('contact_us.html')" class="mui-table-view-cell">
					<span class="padding_tb_5px">联系我们</span>
				</li>
				<li onclick="openNewPage('share_App.html')" class="mui-table-view-cell">
					<span>分享APP</span>
				</li>
				<li onclick="openNewPage('feedback.html')" class="mui-table-view-cell">
					<span>反馈意见</span>
				</li>
				<li class="mui-table-view-cell" id="clear_cache">
					<span>清除缓存</span>
					<p class="mui-pull-right">1M</p>
					<a href="###" id="refresh"><i class="mui-icon iconfont">&#xe623;</i></a>
					
				</li>
				<li onclick="openNewPage('current_version.html')" class="mui-table-view-cell">
					<span>当前版本</span>
				</li>
			</ul>
			<ul class="mui-table-view bg_white ">
				<li class="mui-table-view-cell exit_btn">
					<span class="padding_tb_5px colorRed">退出登录</span>
				</li>
			</ul>
		</div>
	</body>
	<script src="../js/mui.min.js"></script>
	<script src="../js/open.js"></script>
	<script src="../js/jquery.min.js"></script>
	<script type="text/javascript">
		(function($, doc) {
			$.init();
		})(mui, document);

		//清除缓存
		document.addEventListener('plusready', function() {
			$('#clear_cache').on('tap', function() {
				$('#refresh').animate({ 'top': '11px' }, '300');
				setTimeout(function() {
					$('#refresh').addClass('run');
				})
				setTimeout(function() {
					$('#refresh').removeClass('run');
					$('#refresh').animate({ 'top': '-22px' }, 300);
					$('#clear_cache p').html('0');
					mui.toast('已清除');
				}, 3000)
			})
		})

		var auths = [];
		document.addEventListener('plusready', function() {
			plus.oauth.getServices(function(service) {
				auths = service;
			}, function(e) {
				toast('获取第三方登录失败!');
			})

			$('.exit_btn').on('tap', function() {
				plus.nativeUI.confirm("您确认退出登录吗？", function(e) {
					if(e.index == 0) {
						window.plus.bridge.execSync("community", "exit", "退出登录");
						plus.storage.removeItem('uid');
						plus.storage.removeItem('merchant');   
						authLogout();
						plus.runtime.restart();
					}
				}, '' , ['确定', '取消']);
			})

		}, false);

		function authLogout() {
			for(var i in auths) {
				var s = auths[i];
				if(s.authResult) {
					s.logout(function(e){
						//alert("注销登录认证成功！");
					}, function(e) {
						//alert("注销登录认证失败！");
					});
				}
			}
		}

		function nwaiting() {
			var nwaiting = plus.nativeUI.showWaiting(); //显示原生等待框
			var originWebView = plus.webview.currentWebview();
			var webviewContent = plus.webview.create('./login.html', 'login.html', {}, {
				fid: 1
			}); //后台创建webview并打开show.html
			webviewContent.addEventListener("loaded", function() { //注册新webview的载入完成事件
				nwaiting.close(); //新webview的载入完毕后关闭等待框
				webviewContent.show("slide-in-right", 0);
				originWebView.close();
			}, false);
		}
	</script>

</html>